from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.core.urlresolvers import reverse
from django.template import RequestContext, Context
from django.forms import ModelForm

from videosoft.apps.feedback.models import Comment

class CommentForm(ModelForm):
	class Meta:
		model = Comment

def index(request):
	if request.method == 'POST':
		form = CommentForm(request.POST)

		if form.is_valid():
			form.save()
			return HttpResponseRedirect('/feedback/thanks/')
	else:
		form = CommentForm()
		
	ctx = RequestContext(request, {'form': form})
	return render_to_response('feedback/index.html', ctx)
